package de.ikano.demo.polyglott.utils;

import javax.faces.context.FacesContext;

public class ELResolveUtil {

  private ELResolveUtil() {
  }

  public static <T> T getBean(String beanName, Class<T> beanType) {
    return getValueFromEL("#{" + beanName + "}", beanType);
  }

  public static <T> T getValueFromEL(String expression, Class<T> expectedType) {
    FacesContext ctx = FacesContext.getCurrentInstance();
    return (T) ctx.getApplication().evaluateExpressionGet(ctx, expression, expectedType);
  }
}